package day021.homework.p8;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

public class TcpClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 9090);
        FileOutputStream fos = new FileOutputStream("D:\\java\\bbb.png");
        InputStream netInput = socket.getInputStream();

        byte[] buf = new byte[1024];
        int len = -1;
        while ((len = netInput.read(buf)) != -1) {
            fos.write(buf, 0, len);
        }

        socket.close();
        fos.close();
    }
}
